package cn.yj.frame.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author 永健
 * @since 2022-01-18 21:50
 */
public class BeanUtils implements ApplicationContextAware {

    private static ApplicationContext app;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        app = applicationContext;
    }

    public static <T> T getBean(String beanName) {
        return (T) app.getBean(beanName);
    }
}
